package d0317;

public class ThreadStopExample extends Thread{
    private boolean isRunning=true;

    @Override
    public void run(){
        while(isRunning){
            System.out.println("当前程序正在运行");
        }
    }

    public  void stopThred(){
        isRunning=false;
    }

    public static void main(String[] args) throws InterruptedException {
        ThreadStopExample threadStopExample=new ThreadStopExample();
        threadStopExample.start();
        sleep(1);
        threadStopExample.stopThred();
    }
}
